<%@page contentType="text/html; charset=utf-8"%>
<%@ include file="../inc/TagLibs.jsp"%>
<c:set var="pageTitle" value="业务单打印" />
<%@ include file="../inc/PrintTitle.jsp"%>
<head>
<script src="/js/popup_ext.js"></script>
<script language="javascript">
	function doPrint(){
		ShowConfirm('确认框','确定开始打印吗？',340,80,"doPrintCallBack()");
	}
	function doPrintCallBack(){
		if(popRetVal!=null){
			document.getElementById("noPrinSpan").style.display="none";
			doPrintLog();
		}
	}
	function doPrintLog(){
		var xmlHttp=createXMLHttpRequest();
		xmlHttp.open("GET", "/business/BusinessBillPrintLog.ihtm?id=${record.businessBill.id}&type=LITTLE&cost=${record.businessBill.cost}");
		xmlHttp.onreadystatechange = function(){callback(xmlHttp)};
		xmlHttp.send(null);
	}
	function callback(xmlHttp){
		if (xmlHttp.readyState == 4) {
	  		if (xmlHttp.status == 200) {
	  			var resTxt=xmlHttp.responseText;
	  			if(resTxt=="NO_LOGIN"){
	  				ShowAlert('提示框','你还没登录或已经超时，请重新登录。',200,100);
	  			}else if(resTxt=="OK"){
					printContent("管理易-小票","${enterpriseInfo.doPrint}","${enterpriseInfo.printWidth}",160);
	  			}
	  			document.getElementById("noPrinSpan").style.display="";
			}
		}
	}
	function doCancel(){
		window.close();
	}
	function showTotalDiv(imprest,favCost,cost,adjuCost,collCost,exam,divId){
		var str="";
		if(favCost==0){
			str=str+"<b>合计:</b>";
		}else{
			str=str+"<b>优惠:</b>"+favCost+"</b><br/><b>折后合计:</b>";
		}
		str=str+getBigMoney(""+cost);
		str=str+"<b>￥</b>"+cost+"<br/>";
		str=str+"<b>调账:</b>"+adjuCost+"<br/>";
		str=str+"<b>已收:</b>";
		if(exam=='Y'){
			str=str+collCost+"&nbsp;";
		}else{
			str=str+imprest+"&nbsp;";
		}
		str=str+"<b>欠款:</b>";
		if(exam=='Y'){
			str=str+parseScale(abateMul(addMul(cost,adjuCost),collCost),2);
		}else{
			str=str+parseScale(abateMul(addMul(cost,adjuCost),imprest),2);
		}
		document.getElementById(divId).innerHTML=str;
	}
</script>
</head>
<body style="background-color:#FFFFFF">
<br><br>
<table width="158" align="center" border="1" cellspacing="1" cellpadding="1" class="label_table">
	<tr>
		<td>
			<table width="100%" align="center" border="0" cellspacing="0" cellpadding="0" class="label_table">
				<tr> 
				  <td align="center" class="FontMedium" >${record.businessBill.billCode}</td>
				</tr>
				<tr> 
				  <td class="FontMedium"><b>客户：</b>${record.clientName}</td>
				</tr>
				<tr> 
				  <td class="FontMedium"><b>联系人：</b><c:if test="${record.busiPphone=='Y'}">${record.businessBill.linkman}</c:if></td>
				</tr>
				<tr> 
				  <td class="FontMedium"><b>交货日期：</b><c:if test="${record.businessBill.deliverDate!=null}"><fmt:formatDate value="${record.businessBill.deliverDate}" pattern="MM-dd HH:mm"/></c:if></td>
				</tr>		
				<tr> 
				  <td class="FontMedium"> ----------------------- </td>
				</tr>		
				<c:forEach var="item" items="${record.items}" varStatus="i"> 
				<tr> 
				  <td class="FontMedium"><b>项目：</b><c:out value="${item.makeTypeName}" /></td>
				</tr>
				<tr> 
				  <td class="FontMedium"><b>内容：</b><commonTag:parseEnterToBr source="${item.businessBillItem.finishedContent}" /></td>
				</tr>
				<tr> 
				  <td class="FontMedium"><b>材质：</b><c:out value="${item.businessBillItem.proName}" /></td>
				</tr>
				<tr> 
				  <td class="FontMedium"><b>规格：</b><commonTag:parseEnterToBr source="${item.businessBillItem.specification}" /><c:if test="${item.businessBillItem.priceType=='AREA' || item.businessBillItem.priceType=='LENGTH'}"> x <commonTag:parseBigDecimal source="${item.businessBillItem.amount}" /></c:if></td>
				</tr>
				<tr> 
				  <td class="FontMedium"><b>数量：</b><c:if test="${item.businessBillItem.priceType=='AREA' || item.businessBillItem.priceType=='LENGTH'}"><commonTag:parseBigDecimal source="${item.businessBillItem.squareNum}" /></c:if> <c:if test="${item.businessBillItem.priceType=='AMOUNT'}"><commonTag:parseBigDecimal source="${item.businessBillItem.amount}" /></c:if>  <c:if test="${item.businessBillItem.priceType=='AREA'}">平方米</c:if><c:if test="${item.businessBillItem.priceType=='LENGTH'}"> <c:if test="${item.businessBillItem.lengType=='M'}">米</c:if><c:if test="${item.businessBillItem.lengType=='CM'}">公分</c:if> </c:if> <c:if test="${item.businessBillItem.priceType=='AMOUNT'}">${item.businessBillItem.unit}</c:if>	</td>
				</tr>
				<tr> 
				  <td class="FontMedium"><b>单价：</b><commonTag:parseBigDecimal source="${item.businessBillItem.unitPrice}" /> <b>金额：</b><commonTag:parseBigDecimal source="${item.businessBillItem.cost}" /></td>
				</tr>		
				<tr> 
				  	<td class="FontMedium"> ----------------------- </td>
				</tr>		
				</c:forEach> 
						
				<tr>
					<td class="FontMedium" id="totalDiv">&nbsp;</td>
				</tr>
				
				<tr> 
				  	<td class="FontMedium"> ----------------------- </td>
				</tr>		
				<tr> 
				  <td class="FontMedium" >${enterpriseInfo.shortName} ${enterpriseInfo.phone} ${enterpriseInfo.address}<br/> 
				  ${record.businessBill.createrName} <fmt:formatDate value="${record.businessBill.orderDate}" pattern="MM-dd HH:mm"/></td>
				</tr>				
			  </table>
		</td>
	</tr>
</table>
<table align="center" id="noPrinSpan">
	<tr>
		<td align="center">
			<input type="button" id="printButton" class="Button" value="开始打印" onClick="doPrint();">
			<input type="button" id="cancelButton" class="Button" value=" 退 出 " onClick="doCancel();">
		</td>
	</tr>
</table>
</body>
</html>
<script language="javascript">
	showTotalDiv(${record.businessBill.imprest},${record.businessBill.favCost},${record.businessBill.cost},${record.businessBillExt.adjustCost},${record.businessBillExt.collectedCost},'${record.businessBillExt.examined}','totalDiv');
</script>